<template>
	<view :style="{'background-color':pageBg}" style="float: left;width: 100%;min-height: 100%;">
		<view style="float: left;width: 100%;height: 100%;">
			<view v-for="(item, index) in modes" @click="checkThis(item)"
				class=" tn-margin-top-xl1 tn-padding-top-sm tn-padding-bottom-sm tn-margin-left tn-margin-right bg-color-box css-theme"
				:class="[cueTheme]">
				<tn-list-cell :hover="true" :unlined="true" :fontSize="30" class="css-theme" :class="[cueTheme]">
					<view class="tn-flex tn-flex-col-center css-theme">

						<view class="tn-flex-1 css-theme">{{item.name}}</view>
						<tn-checkbox v-model="item.id==checkedIndex" :size="40" :iconSize="25" activeColor="#18B998"
							shape="circle"></tn-checkbox>
					</view>
				</tn-list-cell>
			</view>
		</view>


		<!-- <view
			class=" tn-margin-top-xl1 tn-padding-top-sm tn-padding-bottom-sm tn-margin-left tn-margin-right bg-color-box">
			<u-grid :col="4" :border="false">
				<u-grid-item v-for="(category, index) in categories" @click="checkThis(category)">
					<view :style="'background-color:'+category.background"
						style="padding: 50rpx;margin-bottom: 10px;border-radius: 5px;position: relative;">
						<view v-if="category.id == checkedIndex" class="tn-icon-success-circle-fill"
							style="position: absolute;top:-5px;right: -5px;background-color: white;border-radius: 30px;"
							:style="'color:'+category.background"></view>
					</view>
					<view class="grid-text">{{ category.name }}</view>
				</u-grid-item>
			</u-grid>
		</view> -->
	</view>
</template>

<script>
	var _self
	// // #ifdef APP-PLUS
	// var Color = plus.android.importClass("android.graphics.Color");
	// plus.android.importClass("android.view.Window");
	// var mainActivity = plus.android.runtimeMainActivity();
	// var window_android = mainActivity.getWindow();
	// window_android.setNavigationBarColor(Color.parseColor("#eb8c76"));
	// // #endif

	export default {
		data() {
			return {
				user: [],
				checkedIndex: 0,
				switchValue: true,
				modes: [

					{
						id: 0,
						name: '日间模式',
						value: 'day-theme',
					},
					{
						id: 1,
						name: '夜间模式',
						value: 'night-theme',
					}
					// ,
					// {
					// 	id: 2,
					// 	name: '公主模式',
					// 	value: 'jade-theme',
					// },
					// {
					// 	id:3,
					// 	name: '鹅黄模式',
					// 	value: 'yellow-theme',
					// },
				],
				categories: [{
						name: '暗黑色',
						background: '#181A13',
						id: 0,
					},
					{
						name: '深棕色',
						background: '#8D3448',
						id: 1,
					},
					{
						name: '浅棕色',
						background: '#C1683E',
						id: 2,
					},
					{
						name: '淡黄色',
						background: '#FABF47',
						id: 3,
					},
					{
						name: '浅绿色',
						background: '#5EAB81',
						id: 4,
					},
					{
						name: '天青色',
						background: '#69B0AC',
						id: 5,
					},
					{
						name: '浅粉色',
						background: '#FA7296',
						id: 6,
					},

					{
						name: '瓦灰色',
						background: '#AAAAAA',
						id: 7,
					},
				],

			}
		},
		onLoad(options) {
			_self = this;
			console.log("当前主题:", this.cueTheme);
			if (this.cueTheme == 'day-theme') {
				this.checkedIndex = 0;
				console.log("1111")
			} else {
				this.checkedIndex = 1;
				console.log("2222")
			}
		},
		computed: {

		},
		onReady() {

		},
		onShow() {
			uni.getStorage({
				key: 'user',
				success: function(res) {
					if (res.data) {
						_self.user = res.data
						// setTimeout(function() {
						// 	_self.getList()
						// }, 200);
					}
				},
				fail: function(e) {
					uni.navigateTo({
						url: '../login/login'
					});
				}
			})

		},
		methods: {
			changeGroup(e) {
				console.log(e)
			},

			radioChange: function(e) {
				//let item = this.items[Number(e.detail.value)].value;
				// this.$store.commit("skinPeeler",item);
				// this.setBarStyle(item[0].value,item[1].value);
			},

			cssEditThemeBut(e) {
				//修改主题
				this.cueGetTheme(e)
				//设置主题缓存
				this.themeCache(e)
				//设置 全局背景色
				this.getSystemBg()

			},
			checkThis(itemThis) {
				this.checkedIndex = itemThis.id

				this.cssEditThemeBut(itemThis.value)
				this.saveData()
			},
			getList() {
				var data = {
					userId: _self.user.id
				}
				this.$api.listUserSet(data).then((res) => {
					var resData = res;
					if (resData.code == "200") {
						if (resData.data.length > 0) {
							if (resData.data[0].theme > 0) {
								_self.checkedIndex = resData.data[0].theme
								
							}
						}
					} 
				})
				
			},

			saveData() {
				var data = {
					userId: _self.user.id,
					theme: _self.checkedIndex,
				}
				this.$api.updateUserSet(data).then((res) => {
					console.log(res);
				})
				
			},
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
		background-color: $page-bg !important;
		// display: flex;
		width: 100%;
		margin: 0px;
	}

	.css-theme {
		// border: 2px solid;
		@include text-color();
		@include base-background();
		@include border-color();
		@include shadow-color();
	}

	// .template-about {
	// 	background-color: $page-bg;
	// 	padding-bottom: 40rpx;
	// }

	.bg-color-box {
		background-color: #fff;
		border-radius: 20rpx
	}

	/* 顶部背景图 start */
	.top-backgroup {
		height: 450rpx;
		z-index: -1;

		.backgroud-image {
			width: 100%;
			height: 450rpx;
			// z-index: -1;
		}
	}

	.top_max_box {
		padding-top: 120rpx;
	}

	/* 顶部背景图 end */

	/* 波浪*/
	@keyframes move_wave {
		0% {
			transform: translateX(0) translateZ(0) scaleY(1)
		}

		50% {
			transform: translateX(-25%) translateZ(0) scaleY(1)
		}

		100% {
			transform: translateX(-50%) translateZ(0) scaleY(1)
		}
	}

	.tnwave {
		overflow: hidden;
		position: absolute;
		z-index: 9999;
		height: 200rpx;
		left: 0;
		right: 0;
		top: 290rpx;
		bottom: auto;
	}

	.waveWrapperInner {
		position: absolute;
		width: 100%;
		overflow: hidden;
		height: 100%;
	}

	.wave {
		position: absolute;
		left: 0;
		width: 200%;
		height: 100%;
		background-repeat: repeat no-repeat;
		background-position: 0 bottom;
		transform-origin: center bottom;
	}

	.bgTop {
		opacity: 0.4;
	}

	.waveTop {
		background-size: 50% 45px;
	}

	.waveAnimation .waveTop {
		animation: move_wave 4s linear infinite;
	}

	.bgMiddle {
		opacity: 0.6;
	}

	.waveMiddle {
		background-size: 50% 40px;
	}

	.waveAnimation .waveMiddle {
		animation: move_wave 3.5s linear infinite;
	}

	.bgBottom {
		opacity: 0.95;
	}

	.waveBottom {
		background-size: 50% 35px;
	}

	.waveAnimation .waveBottom {
		animation: move_wave 2s linear infinite;
	}

	/* 波浪*/

	/* 页面 start*/
	.about-shadow {
		border-radius: 15rpx;
		box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	.about {

		&__wrap {
			position: relative;
			z-index: 1;
			// margin: 20rpx 30rpx;
			margin-top: -330rpx;
		}
	}

	/* 页面 end*/

	/* 用户信息 start */
	.user-info {
		&__container {}

		&__avatar {
			width: 170rpx;
			height: 170rpx;
			border: 8rpx solid rgba(255, 255, 255, 0.05);
			border-radius: 50%;
			overflow: hidden;
			box-shadow: 0rpx 0rpx 80rpx 0rpx rgba(0, 0, 0, 0.15);
		}

		&__nick-name {
			margin-top: 26rpx;
			font-size: 36rpx;
			font-weight: 600;
			text-align: center;
		}
	}

	/* 用户信息 end */
	/* 图标容器1 start */
	.icon1 {
		&__item {
			// width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 40rpx;
				height: 40rpx;
				font-size: 28rpx;
				border-radius: 50%;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;
					background-image: url(https://tnuiimage.tnkjapp.com/cool_bg_image/icon_bg.png);
				}
			}
		}
	}

	/* 图标容器1 end */

	/* 底部tabbar start*/
	.footerfixed {
		position: fixed;
		width: 100%;
		bottom: 0;
		z-index: 999;
		background-color: #FFFFFF;
		box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	.tabbar {
		display: flex;
		align-items: center;
		min-height: 110rpx;
		justify-content: space-between;
		padding: 0;
		height: calc(110rpx + env(safe-area-inset-bottom) / 2);
		padding-bottom: calc(env(safe-area-inset-bottom) / 2);
	}

	.tabbar .action {
		font-size: 22rpx;
		position: relative;
		flex: 1;
		text-align: center;
		padding: 0;
		display: block;
		height: auto;
		line-height: 1;
		margin: 0;
		overflow: initial;
	}

	.tabbar .action .bar-icon {
		width: 100rpx;
		position: relative;
		display: block;
		height: auto;
		margin: 0 auto 10rpx;
		text-align: center;
		font-size: 42rpx;
	}

	.tabbar .action .bar-icon image {
		width: 50rpx;
		height: 50rpx;
		display: inline-block;
	}

	.user-info__nick-name-top {
		font-weight: bold;
		margin-top: 20rpx;
		font-size: 18px;

	}

	.user-info__nick-name-bottom {
		margin-top: 20rpx;
		color: #A8A8A8;
		font-size: 14px;
		letter-spacing: 10px;
	}

	.tn-margin-top-xl1 {
		margin-top: 20rpx;
	}
</style>